import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  Query,
} from '@nestjs/common';
import { StudycontentsortService } from './studycontentsort.service';
import { CreateStudycontentsortDto } from './dto/create-studycontentsort.dto';
import { UpdateStudycontentsortDto } from './dto/update-studycontentsort.dto';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { BaseController } from 'src/common/BaseController';
import { Studycontentsort } from './entities/studycontentsort.entity';
import { QueryListDto } from 'src/common/dto';
@ApiTags('学习内容分类管理')
@Controller('studycontentsort')
export class StudycontentsortController extends BaseController<
  Studycontentsort,
  StudycontentsortService
> {
  constructor(
    private readonly studycontentsortService: StudycontentsortService,
  ) {
    super(studycontentsortService);
  }

  @Post('AddContentSort')
  @ApiOperation({ summary: '添加学习内容分类' })
  async addContentSort(
    @Body() createStudycontentsortDto: CreateStudycontentsortDto,
  ) {
    return this.Success(
      this.studycontentsortService.create(createStudycontentsortDto),
      '添加成功',
    );
  }

  @Get('GetContentSort')
  @ApiOperation({ summary: '获取所有学习内容分类' })
  async findAll(@Query() querylistDto: QueryListDto) {
    return this.Success(
      await this.studycontentsortService.findAll(querylistDto),
      '获取成功',
    );
  }

  @Get(':id')
  @ApiOperation({ summary: '根据 ID 获取学习内容分类' })
  async findOne(@Param('id') id: string) {
    return this.Success(
      await this.studycontentsortService.findOne(+id),
      '获取成功',
    );
  }

  @Patch(':id')
  @ApiOperation({ summary: '根据 ID 更新学习内容分类' })
  async update(
    @Param('id') id: string,
    @Body() updateStudycontentsortDto: UpdateStudycontentsortDto,
  ) {
    return this.Success(
      await this.studycontentsortService.update(+id, updateStudycontentsortDto),
      '更新成功',
    );
  }

  @Delete(':id')
  @ApiOperation({ summary: '根据 ID 删除学习内容分类' })
  async remove(@Param('id') id: string) {
    return this.Success(
      await this.studycontentsortService.remove(+id),
      '删除成功',
    );
  }
}
